/**
 * Created by Administrator on 2015/4/11.
 */
/**
 * Created by Administrator on 15-4-10.
 **/
//取id封装函数
function getId(id){
    return document.getElementById(id);
}
//创建遮幕层

function popMask(){
    var box = getId("insertDate");
    var closeAdv = getId("closeAdv");
    var mask = document.createElement("div");

     mask.setAttribute("id","mask");
    box.style.display="block";
    closeAdv.style.display = "block";
    var boxHeight = box.offsetHeight;
    var boxWidth = box.offsetWidth;

    var maskCss = "position:fixed;left:0;top:0;z-index:999;width:100%;"
        +"height:100%;filter:alpha(opacity=50);"
        +"-moz-opacity:0.2;opacity:0.2;background:#999";
    var boxCss = "display:block;position:fixed;left:50%;top:50%;z-index:1000;margin:-" + boxHeight / 2 + "px 0 0 -" + (boxWidth-80) / 2 + "px;";

    box.style.cssText = boxCss;
    mask.style.cssText = maskCss;
    document.body.appendChild(mask);
}
//点击隐藏遮幕层
function closeAdv(){
    var inserDate = getId("insertDate");
    var clear = getId("closeAdv");
    var mask = getId("mask");
    inserDate.style.display = "none";
    clear.style.display = "none";
    document.body.removeChild(mask);
}
//点击隐藏遮幕层
function cancel(){
    var inserdate = getId("insertDate");
    var c = getId("closeAdv");
    var mask = getId("mask");
    inserdate.style.display = "none";
    c.style.display = "none";
    document.body.removeChild(mask);
}

//老师名字输入框聚焦检测
function  teacherNameFocus(){

    var teacherNameId=getId("teacherNameId")
    teacherNameId.className="import_prompt";
    teacherNameId.innerHTML="1.姓名为中文或英文<br/>2.长度为4-20"
}
//老师名字输入框失去焦点检测
function teacherNameBlur(){
    var teacherName=getId("teacherName");
    var teacherNameId=getId("teacherNameId");
    var reg=/^[\u4e00-\u9fa5]+$/;
    var regE=/^[a-zA-Z]+$/;
    var chinaReg=/[\u4e00-\u9fa5]/g;
    if(!teacherName.value){
        teacherNameId.className="error_prompt";
        teacherNameId.innerHTML="姓名不能为空";
    }else if(!reg.test(teacherName.value) && !regE.test(teacherName.value)){
        teacherNameId.className="error_prompt";
        teacherNameId.innerHTML="1.姓名为中文或英文<br/>2.长度为4-20";
    }else {
        var len = teacherName.value.replace(chinaReg, "ab").length;
        if (len < 4 || len > 20) {
            teacherNameId.className = "error_prompt";
            teacherNameId.innerHTML = "1.姓名为中文或英文<br/>2.长度为4-20";
        }
        else{
            teacherNameId.className = "ok_prompt";
            teacherNameId.innerHTML = "输入正确";
        }
    }
}
//班级名称聚焦检测
function ClassFocus(){
    var classNameId=getId("classNameId");
    classNameId.innerHTML=""
}
//班级名称失去焦点检测
function ClassBlur(){
    var className=getId("className");
    var classNameId=getId("classNameId");
    if(!className.value){
        classNameId.className="error_prompt";
        classNameId.innerHTML="班级不能为空";
    }else{
        classNameId.className = "ok_prompt";
        classNameId.innerHTML = "输入正确";

    }
}
//学校失去焦点检测
function schoolBlur(){
    var schoolName=getId("schoolName");
    var schoolNameId=getId("schoolNameId");
    if(!schoolName.value){
        schoolNameId.className="error_prompt";
        schoolNameId.innerHTML="学校不能为空";
    }else{
        schoolNameId.className = "ok_prompt";
        schoolNameId.innerHTML = "输入正确";

    }
}

//删除信息遮幕层建立
function deleteMask(){
    var box = getId("deleteDate");
    var closeAdiv = getId("closeAdiv");
    var mask = document.createElement("div");
    mask.setAttribute("id","mask");
    box.style.display = "block";
    closeAdiv.style.display = "block";
    var boxHeight = box.offsetHeight;
    var boxWidth = box.offsetWidth;

    var maskCss = "position:fixed;left:0;top:0;z-index:999;width:100%;"
        +"height:100%;filter:alpha(opacity=50);"
        +"-moz-opacity:0.2;opacity:0.2;background:#999";
    var boxCss = "display:block;position:fixed;left:50%;top:50%;z-index:1000;margin:-" + boxHeight / 2 + "px 0 0 -" + (boxWidth-80) / 2 + "px;";

    box.style.cssText = boxCss;
    mask.style.cssText = maskCss;
    document.body.appendChild(mask);
}
//点击隐藏遮幕层
function closeAdiv(){
    var box = getId("deleteDate");
    var closeAdiv = getId("closeAdiv");
    var mask = getId("mask");
    box.style.display = "none";
    closeAdiv.style.display = "none";
    document.body.removeChild(mask);
}
//点击隐藏遮幕层
function cancel2(){
    var box = getId("deleteDate");
    var closeAdiv = getId("closeAdiv");
    var mask = getId("mask");
    box.style.display = "none";
    closeAdiv.style.display = "none";
    document.body.removeChild(mask);
}
//下拉菜单隐藏检测
var i = 0;
function selectSchool(dd){
    var u=getId("chengduCity");
    var img=getId("images")
    if(i==0){
        u.style.height="70px";
        dd.childNodes[0].style.width="100%"
        img.setAttribute("src","images/bg4.png")

        i++;
    }else{
        u.style.height="0px";
        img.setAttribute("src","images/bg3.png")
        dd.childNodes[0].style.width="0%"
        i=0;
    }

}
var j=0;
function selectSchool2(dd){
    var u=getId("mianyangCity");
    var img=getId("image")
    if(j==0){
        u.style.height="70px";
        img.setAttribute("src","images/bg4.png")
        dd.childNodes[0].style.width="100%"
        j++;
    }else{
        u.style.height="0px";
        img.setAttribute("src","images/bg3.png")
        dd.childNodes[0].style.width="0%"
        j=0;
    }

}

